package com.daigoudao.web.model;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.daigoudao.config.ConfigManager;
import com.daigoudao.util.Constants;
import com.daigoudao.util.ImageUtil;
import com.daigoudao.util.NumberUtil;

/**
 * 代购信息
 * 
 * @author zheng
 * 
 */
@SuppressWarnings("serial")
public class CanBuyModel extends BasePageModel {

	/**
	 * 用户信息
	 */
	private UserModel user = new UserModel();

	/**
	 * 商品名称
	 */
	private String goodsName;

	/**
	 * 价格
	 */
	private double price;

	/**
	 * 商品图片URL
	 */
	private List<String> images;

	/**
	 * 币种 1 人民币 2 港币 3 美元 4 欧元 5 日元
	 */
	private int currency;

	/**
	 * 服务费
	 */
	private double serviceFee;

	/**
	 * 佣金比例
	 */
	private int ratio;

	/**
	 * 商品来源 0 不限 1 大型超市 2 便利店 3 专卖店 4 生产厂家 5 其他
	 */
	private int source;

	private int goodsPosition;

	/**
	 * 单据要求, 0 无要求 1 小票 2 发票 3 小票或是发票
	 */
	private int receipts;

	/**
	 * 商品描述
	 */
	private String description;

	/**
	 * 商品类别编号
	 */
	private int categoryId;

	/**
	 * 商品类别名称
	 */
	private String categoryName;

	/**
	 * 所属区域id
	 */
	private int areaId;

	/**
	 * 所属区域名
	 */
	private String areaName;

	private int canId;

	/**
	 * 国内价
	 */
	private double domesticPrice;

	/**
	 * 商品详情
	 */
	private String details;

	/**
	 * 服务保障等信息
	 */
	private String serviceAssurance;

	/**
	 * 是否公开
	 */
	private int isOpen = -1;

	/**
	 * 该代购信息交易的数量
	 */
	private int transNum;

	private String ts;

	private int tagId;

	private String image;

	// 0、正常 1、暂停 2、下线
	private int status = -1;

	private List<String> absoluteImages;

	private List<String> images300 = new ArrayList<String>();

	private List<String> images50 = new ArrayList<String>();

	private Logistics logistics = new Logistics();

	private int notEqualUserId;

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getIsOpen() {

		return isOpen;
	}

	public void setIsOpen(int isOpen) {
		this.isOpen = isOpen;
	}

	public int getTransNum() {
		return transNum;
	}

	public void setTransNum(int transNum) {
		this.transNum = transNum;
	}

	public int getSource() {
		return source;
	}

	public void setSource(int source) {
		this.source = source;
	}

	public String getDetails() {
		return details;
	}

	public void setDetails(String details) {
		this.details = StringUtils.trimToEmpty(details);
	}

	public String getServiceAssurance() {
		return serviceAssurance;
	}

	public void setServiceAssurance(String serviceAssurance) {
		this.serviceAssurance = StringUtils.trimToEmpty(serviceAssurance);
	}

	public int getCanId() {
		return canId;
	}

	public void setCanId(int canId) {
		this.canId = canId;
	}

	public double getDomesticPrice() {
		return NumberUtil.getBigDecimal(domesticPrice, Constants.SCALE)
				.doubleValue();
	}

	public void setDomesticPrice(double domesticPrice) {
		this.domesticPrice = domesticPrice;
	}

	public UserModel getUser() {
		return user;
	}

	public void setUser(UserModel user) {
		this.user = user;
	}

	public String getGoodsName() {
		return goodsName;
	}

	public void setGoodsName(String goodsName) {
		this.goodsName = StringUtils.trimToEmpty(goodsName);
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public List<String> getImages() {
		return images;
	}

	public void setImages(List<String> images) {
		this.images = images;
		if (images != null && images.size() > 0) {
			absoluteImages = new ArrayList<String>();
			for (String image : images) {

				absoluteImages.add(ConfigManager
						.getConfigString("upload.resUrl") + image);
				images300.add(ConfigManager.getConfigString("upload.resUrl")
						+ ImageUtil.getImageFileName(image, 300));
				images50.add(ConfigManager.getConfigString("upload.resUrl")
						+ ImageUtil.getImageFileName(image, 50));
			}
		}
	}

	public int getCurrency() {
		return currency;
	}

	public void setCurrency(int currency) {
		this.currency = currency;
	}

	public double getServiceFee() {
		return NumberUtil.getBigDecimal(serviceFee, Constants.SCALE)
				.doubleValue();
	}

	public void setServiceFee(double serviceFee) {
		this.serviceFee = serviceFee;
	}

	public int getReceipts() {
		return receipts;
	}

	public void setReceipts(int receipts) {
		this.receipts = receipts;
	}

	public String getDescription() {
		return StringUtils.trimToEmpty(description);
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(int categoryId) {
		this.categoryId = categoryId;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public int getAreaId() {
		return areaId;
	}

	public void setAreaId(int areaId) {
		this.areaId = areaId;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public int getGoodsPosition() {
		return goodsPosition;
	}

	public void setGoodsPosition(int goodsPosition) {
		this.goodsPosition = goodsPosition;
	}

	public String getTs() {
		return ts;
	}

	public void setTs(String ts) {
		this.ts = ts;
	}

	public int getTagId() {
		return tagId;
	}

	public void setTagId(int tagId) {
		this.tagId = tagId;
	}

	public int getRatio() {
		return ratio;
	}

	public void setRatio(int ratio) {
		this.ratio = ratio;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public List<String> getAbsoluteImages() {
		return absoluteImages;
	}

	public void setAbsoluteImages(List<String> absoluteImages) {
		this.absoluteImages = absoluteImages;
	}

	public Logistics getLogistics() {
		return logistics;
	}

	public void setLogistics(Logistics logistics) {
		this.logistics = logistics;
	}

	public int getNotEqualUserId() {
		return notEqualUserId;
	}

	public void setNotEqualUserId(int notEqualUserId) {
		this.notEqualUserId = notEqualUserId;
	}

	public String getImage200() {
		String imagePath = Constants.DEFAULT_PRODUCT_PIC;
		if (images != null || images.size() > 0) {
			imagePath = ImageUtil.getImageFileName(images.get(0), 200);
		}
		return ConfigManager.getConfigString("upload.resUrl") + imagePath;
	}

	public List<String> getImages300() {
		return images300;
	}

	public List<String> getImages50() {
		return images50;
	}
}
